Skip to content

SimplePropertyMapping/CalculateMapping: skip inconvertible per-class unit specializations - #854

Open
ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-specific-property-inconvertible-unit-crash
Open

ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-specific-property-inconvertible-unit-crash

Conversation

@ManasBagul23

@ManasBagul23 ManasBagul23 commented Oct 14, 2026 •

Copy link
Copy Markdown

Problem

Both SimplePropertyMapping.writeUnitValue and CalculateMapping.writeUnitValue already guard against calling toStandardUnit()/fromStandardUnit() on an InconvertibleUnitDatatype for the property's own matched unit — the #630 fix in SimplePropertyMapping, and the top-level unit.isInstanceOf[InconvertibleUnitDatatype] check in CalculateMapping (the latter addressed for the conversion itself in #853).

But both functions also separately loop over context.ontology.specializations — a per-class override of the property's range, looked up independently of the property's own unit — and call fromStandardUnit() on whatever specificPropertyUnit that lookup returns, unconditionally:

for(specificPropertyUnit <- context.ontology.specializations.get((currentClass, ontologyProperty)))
{
     val outputValue = specificPropertyUnit.fromStandardUnit(stdValue)
     ...
}

Currency units (usDollar, euro, poundSterling, japaneseYen, russianRouble, unitedArabEmiratesDirham, ...) are registered as InconvertibleUnitDatatype in OntologyDatatypes.scala. So a class that specializes a dimension property (e.g. a money amount like budget/revenue) to one of these currencies hits the exact same always-throws fromStandardUnit() → UnsupportedOperationException("Tried to convert inconvertible unit") — the same failure reported in #582 — regardless of whether the property's own matched unit was convertible. SimplePropertyMapping is the common, everyday property-mapping path (used for any infobox property with a unit/dimension range), so this is plausibly the dominant real-world trigger for that exception, more so than the narrower CalculateMapping path fixed in #853.

Fix

Skip writing that specific-class property when its specialized unit is inconvertible, consistent with how the property's own unit is already handled — there's no meaningful "standard unit" basis to convert a currency amount from, so fabricating a value would be as wrong as crashing.

Related to #582 (same failure, different/more common trigger than #853).

Summary by CodeRabbit

  • Bug Fixes
    • Prevented mapping failures when a class-specific unit cannot be converted. Values for those properties are now skipped.

…unit specializations

Both writeUnitValue() implementations already guard against calling
toStandardUnit()/fromStandardUnit() on an InconvertibleUnitDatatype
for the propertys own matched unit (the dbpedia#630 fix in
SimplePropertyMapping, and the top-level check in CalculateMapping).

But both also separately loop over context.ontology.specializations
-- a per-class override of the property range, independent of the
propertys own unit -- and call fromStandardUnit() on whatever
specificPropertyUnit that lookup returns, unconditionally. Currency
units (usDollar, euro, poundSterling, japaneseYen, russianRouble,
unitedArabEmiratesDirham, ...) are registered as
InconvertibleUnitDatatype in OntologyDatatypes.scala, so a class
specializing a dimension property (e.g. a money amount) to one of
these currencies hits the exact same always-throws
fromStandardUnit()/UnsupportedOperationException("Tried to convert
inconvertible unit") this time regardless of whether the property own
matched unit was convertible.

Skip writing that specific-class property when its specialized unit
is inconvertible, consistent with how the property own unit is
already handled, rather than crash or fabricate a value with no
meaningful standard-unit basis.

Related to dbpedia#582
Copilot AI balanced review requested due to automatic review settings October 14, 2026 19:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f3f7911-f774-4ef2-bf26-f4d7701794ce
📥 Commits

Reviewing files that changed from the base of the PR and between b66cb8b and 282ced3.

📒 Files selected for processing: 2
  • core/src/main/scala/org/dbpedia/extraction/mappings/CalculateMapping.scala
  • core/src/main/scala/org/dbpedia/extraction/mappings/SimplePropertyMapping.scala

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Both CalculateMapping and SimplePropertyMapping now skip class-specific properties with inconvertible specialized units before conversion and output.

Changes: Unit Specialization Output

Layer / File(s) Summary
Filter specialized units
core/src/main/scala/org/dbpedia/extraction/mappings/CalculateMapping.scala, core/src/main/scala/org/dbpedia/extraction/mappings/SimplePropertyMapping.scala
Both writeUnitValue implementations skip inconvertible specialized units instead of attempting conversion and producing specific-property output.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 282ce

Both mapping paths skip inconvertible class-specific outputs while preserving generic output for convertible inputs; no merge-blocking risk was identified.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: both mappings skip inconvertible per-class unit specializations.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants